<%-- 
    Document   : paymententrydb
    Created on : Jan 14, 2013, 9:46:43 PM
    Author     : Bittuji
--%>

<%@page import="java.text.SimpleDateFormat"%>
<%@page contentType="text/html" pageEncoding="UTF-8" import="java.util.Date"%>
<%@include  file="db.jsp" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <%
        
        String prid = request.getParameter("prid");
        String prname = request.getParameter("prname");
        String[] voucher = request.getParameterValues("voucher");
        SimpleDateFormat format = new SimpleDateFormat("dd-MM-yyyy");
        Date date = format.parse(request.getParameter("date"));
        java.sql.Date rpsqlDate = new java.sql.Date(date.getTime());
        
        float amt = Float.parseFloat(request.getParameter("amount"));
        String ptype = request.getParameter("paytype");
        
        for(int i=0;i<voucher.length;i++)
                       {
        String sql = "INSERT INTO `payment_entry`(`party_id`, `party_name`, `date`, `voucher`, `amount`, `payment_type`) VALUES (?,?,?,?,?,?)";
        
        PreparedStatement pstmt = con.prepareStatement(sql);
        
        pstmt.setString(1, prid);
        pstmt.setString(2, prname);
        pstmt.setDate(3, rpsqlDate);
        pstmt.setString(4, voucher[i]);
        pstmt.setFloat(5, amt);
        pstmt.setString(6, ptype);
        
        int result = pstmt.executeUpdate();
        
        if(result==1)
            System.out.println("data inserted");
        
               }
        %>
    </body>
</html>
